import { SkSVG, useSVG } from '@shopify/react-native-skia';
import { useGetTheme } from './useTheme';

// TODO: 少了一个电池的暗色图标，设计稿上现在还没有
function getSvg(name: string, colorScheme: 'dark' | 'light'): number {
  const fullName = colorScheme + '-' + name;
  switch (fullName) {
    case 'light-pv':
      return require('@/assets/icon/skia/pv-light.svg.html');
    case 'light-battery':
      return require('@/assets/icon/skia/battery-light.svg.html');
    case 'light-load':
      return require('@/assets/icon/skia/load-light.svg.html');
    case 'light-grid':
      return require('@/assets/icon/skia/grid-light.svg.html');
    case 'dark-pv':
      return require('@/assets/icon/skia/pv-dark.svg.html');
    case 'dark-battery':
      return require('@/assets/icon/skia/battery-light.svg.html');
    case 'dark-load':
      return require('@/assets/icon/skia/load-dark.svg.html');
    case 'dark-grid':
      return require('@/assets/icon/skia/grid-dark.svg.html');
    default:
      return require('@/assets/icon/skia/pv-light.svg.html');
  }
}

const useNamedThemeSkiaSvg = (name: string): SkSVG | null => {
  const theme = useGetTheme();
  return useSVG(getSvg(name, theme));
};

export default useNamedThemeSkiaSvg;